<template>
	<view>
		<cu-custom :bgColor="'bg-' + background + '-gradient'" :isBack="true" url="../index/index">
			<block slot="backText">返回</block>
			<block slot="content">舔狗语录</block>
		</cu-custom>
		<view class="dog-container">
			<view class="content">{{ dogStr }}</view>
			<view class="time">{{ time }}</view>
			<view class="operation">
				<view @click="handleCopy">
					复制
					<text class="lg text-gray cuIcon-copy icon"></text>
				</view>
				<view @click="getFuckDogStr">
					换一个
					<text class="lg text-gray cuIcon-refresh icon"></text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { soul } from '@/config/dogList.js';
import { getDate } from '../../utils/index.js';
export default {
	data() {
		return {
			background: '',
			dogStr: '',
			time: getDate()
		};
	},
	onLoad(e) {
		this.background = e.background;
		this.getFuckDogStr();
	},
	methods: {
		getFuckDogStr() {
			let str=soul[Math.floor(Math.random() * soul.length)];
			this.dogStr=str.replace(/[*|“|”]/g,"")
		},

		handleCopy() {
			uni.setClipboardData({
				data: this.dogStr,
				success: () => {
					uni.showToast({
						title: '复制成功'
					});
				}
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.dog-container {
	padding: 0 25px;
	box-sizing: border-box;
	.content {
		letter-spacing: 1.5px;
		text-align: justify;
		font-size: 32rpx;
		text-indent: 18px;
		line-height: 26px;
		margin-top: 50%;
		transform: translateY(-50%);
	}
	.time {
		text-align: right;
		margin-top: 15px;
		font-size: 30rpx;
	}
	.operation {
		display: flex;
		justify-content: space-around;
		margin-top: 38px;
		font-size: 32rpx;
		color: #3078e6;
		font-weight: bold;
		.icon {
			margin-left: 3px;
			color: #3078e6;
		}
	}
}
</style>
